package org.diysearch.models;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.diysearch.interfaces.Model;

public class User extends BaseModel implements Model {
	private int id;
	private String username;
	private String password;
	private String email;
	private int status;
	private int permissions;
	private Date dateAdded;
	private Date dateLastModified;
	private int authType;
	private String authenticator;
	private int rating;
	private String token;
	
	private List<UserElement> elements;
	private List<UserIp> ipAddrs;
	private List<Tag> tags;
	private List<Comment> comments;
	private List<Link> links;
	
	public User() {
		elements = new ArrayList<UserElement>();
		ipAddrs = new ArrayList<UserIp>();
		tags = new ArrayList<Tag>();
		comments = new ArrayList<Comment>();
		links = new ArrayList<Link>();
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public int getRating() {
		return rating;
	}

	public void setRating(int rating) {
		this.rating = rating;
	}

	public String getAuthenticator() {
		return authenticator;
	}

	public void setAuthenticator(String authenticator) {
		this.authenticator = authenticator;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getAuthType() {
		return authType;
	}

	public void setAuthType(int authType) {
		this.authType = authType;
	}

	public List<Comment> getComments() {
		return comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	public List<Link> getLinks() {
		return links;
	}

	public void setLinks(List<Link> links) {
		this.links = links;
	}

	public List<Tag> getTags() {
		return tags;
	}

	public void setTags(List<Tag> tags) {
		this.tags = tags;
	}

	public String getAliasName() {
		// TODO Auto-generated method stub
		return "user";
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getPermissions() {
		return permissions;
	}

	public void setPermissions(int permissions) {
		this.permissions = permissions;
	}

	public Date getDateAdded() {
		return dateAdded;
	}

	public void setDateAdded(Date dateAdded) {
		this.dateAdded = dateAdded;
	}

	public Date getDateLastModified() {
		return dateLastModified;
	}

	public void setDateLastModified(Date dateLastModified) {
		this.dateLastModified = dateLastModified;
	}

	public List<UserElement> getElements() {
		return elements;
	}

	public void setElements(List<UserElement> elements) {
		this.elements = elements;
	}

	public List<UserIp> getIpAddrs() {
		return ipAddrs;
	}

	public void setIpAddrs(List<UserIp> ipAddrs) {
		this.ipAddrs = ipAddrs;
	}
	
	public UserElement getElementByName(String key) {
		UserElement element = null;
		if (elements != null && elements.size() > 0) {
			for (UserElement ue : elements) {
				if (ue.getKey().equalsIgnoreCase(key)) {
					element = ue;
					break;
				}
			}
			return element;
		} else {
			return null;
		}
	}
	
}
